package com.zsrt.java.day20161223.lh.day1223.Demo05;


import static org.junit.Assert.*;

import org.junit.Test;

public class ForDemo {
	/**
	 * for 用法
	 * 从1开始加即达到10  每次步长为1
	 * 分三步
	 * 1.定义哪里开始 包含
	 * 2.定义哪里结束 包含
	 * 3.每次的变化是多少 步长 step 1 步长一定要写在{}里面
	 * @throws Exception
	 */
	@Test
	public void for01() throws Exception {
		int sum=0;
		for(int begin=1;begin<=100;begin++){
			sum=sum+begin;
		}
		System.out.println(sum);
	}
	/**
	 * 
	 * @throws Exception
	 */
	@Test
	public void for02() throws Exception {
		int sum=0;
		for(int begin=19;begin<=99;begin+=20){
			sum=sum+begin;
		}
		System.out.println(sum);
	}
     
	@Test
	public void for3() throws Exception {
		for(int begin=1;begin<=10;begin++){
			System.out.print("*");
		}
		//换行
		System.out.println();
		
		
	}
	@Test
	public void for4() throws Exception {
		for(int outer=1;outer<=5;outer++){
			for(int begin=1;begin<=10;begin++){
				System.out.print("*");
			}
			//换行
			System.out.println();
		}
		
	}
	@Test
	public void for5() throws Exception {
		for(int outer=1;outer<=5;outer++){
			for(int begin=1;begin<=10;begin++){
				System.out.print("*");
			}
			//换行
			System.out.println();
		}
	}
	
	@Test
	public void for6() throws Exception {
		for(int hang=1;hang<=5;hang++){
			for(int star=1;star<=hang;star++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
	
	@Test
	public void for7() throws Exception {
		for(int hang=1;hang<=6;hang++){
			for(int star=6;hang<=star;star--){
				System.out.print("*");
			}
			System.out.println();
		}
	}
	@Test
	public void for8() throws Exception {
		
		
	}
}
